package aerys.minko.scene.stardust
{
	import aerys.common.Factory;
	import aerys.minko.render.Scene3DVisitor;
	import aerys.minko.scene.AbstractScene3D;
	import aerys.minko.scene.IScene3D;
	import aerys.minko.scene.group.IGroup3D;
	import idv.cjcat.stardust.common.handlers.ParticleHandler;
	import idv.cjcat.stardust.common.handlers.PollingStation;
	
	import flash.utils.Dictionary;
	
	import idv.cjcat.stardust.common.events.EmitterEvent;
	import idv.cjcat.stardust.common.particles.ParticleIterator;
	import idv.cjcat.stardust.threeD.emitters.Emitter3D;
	import idv.cjcat.stardust.threeD.particles.Particle3D;
	
	public class ParticleEmitter3D extends AbstractScene3D
	{
		private var _emitter	: Emitter3D			= null;
		private var _frame		: uint				= 0;
		private var _particleHandler:MinkoParticleHandler;
		
		public function ParticleEmitter3D(myEmitter : Emitter3D)
		{
			super();
			
			_emitter = myEmitter;
			
			_emitter.particleHandler = _particleHandler = new MinkoParticleHandler();
		}
		
		override public function updated(visitor : Scene3DVisitor) : Boolean
		{
			var updated	: Boolean	= super.updated(visitor);
			var parent 	: IGroup3D 	= visitor.parent as IGroup3D;
			
			_particleHandler.parent = parent;
			
			if (visitor.frame != _frame || !_frame)
			{
				_frame = visitor.frame;
				_emitter.step();
			}
			
			return updated;
		}
	}
}



